package run;

import ctu.kfad.run.ClassFileRepository;
import ctu.kfad.run.InstanceController;
import ctu.kfad.run.NotEnoughSpaceException;
import ctu.kfad.run.iterpreter.Interpreter;
import ctu.kfad.run.memory.MemoryManager;
import executable.instance.ClassWithAllFieldTypeSize;
import org.apache.bcel.classfile.JavaClass;
import org.apache.bcel.classfile.Method;
import org.junit.Before;
import org.junit.Test;

import java.io.File;

public class GCTestClassWithAllFieldSize {

    private JavaClass clazz;
    private ClassFileRepository repository;
    private MemoryManager memoryManager;
    private InstanceController instanceController;

    @Before
    public void init() {
        repository = new ClassFileRepository(new File("target/classes"));
        clazz = repository.loadClass(ClassWithAllFieldTypeSize.class.getName());
        memoryManager = new MemoryManager();
        instanceController = new InstanceController(repository, memoryManager);

    }

    @Test(expected = NotEnoughSpaceException.class)
    public void test02() {
        final Method method = TestUtil.findMethodByName("fillMemory", clazz);
        final Interpreter interpreter = new Interpreter(null, instanceController, clazz, method);
        interpreter.interpret();
    }

    @Test
    public void test03() {
        final Method method = TestUtil.findMethodByName("fillMemoryInMoreMethods", clazz);
        final Interpreter interpreter = new Interpreter(null, instanceController, clazz, method);
        interpreter.interpret();
    }


}
